import {requestGet, requestPost, requestDelete, requestPut, requestUpload, requestDownload} from './request';

let baseUrl = '';
let baseUrl2 = 'http://dhappapi.twkd56.net/'

export const http = {
	get(url, ...params) {
		return requestGet(`${baseUrl}${url}`, ...params);
	},
	post(url, ...params) {
		return requestPost(`${baseUrl}${url}`, ...params);
	},
	post2(url, ...params) {
		return requestPost(`${baseUrl2}${url}`, ...params);
	},
	delete(url, ...params) {
		return requestDelete(`${baseUrl}${url}`, ...params);
	},
	put(url, ...params) {
		return requestPut(`${baseUrl}${url}`, ...params);
	},
	upload(url, ...params) {
		return requestUpload(`${baseUrl}${url}`, ...params);
	},
	download(url, ...params) {
		return requestDownload(url, ...params);
	}
};

const install = (Vue, configBaseUrl) => {
	baseUrl = configBaseUrl;
	
	Vue.prototype.$domain = baseUrl;
	uni.$domain = baseUrl;
	
	uni.$http = http;
	Vue.prototype.$http = http;
};

export default install;